/*    */ package com.zimbra.cs.service.account;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AccountConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.gal.GalSearchControl;
/*    */ import com.zimbra.cs.gal.GalSearchParams;
/*    */ import com.zimbra.cs.gal.GalSearchResultCallback;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.type.GalSearchType;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class AutoCompleteGal
/*    */   extends GalDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 39 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 40 */     Account account = getRequestedAccount(getZimbraSoapContext(context));
/*    */     
/* 42 */     if (!canAccessAccount(zsc, account)) {
/* 43 */       throw ServiceException.PERM_DENIED("can not access account");
/*    */     }
/* 45 */     String name = request.getAttribute("name");
/* 46 */     String typeStr = request.getAttribute("type", "account");
/* 47 */     GalSearchType type = GalSearchType.fromString(typeStr);
/*    */     
/* 49 */     boolean needCanExpand = request.getAttributeBool("needExp", false);
/*    */     
/* 51 */     String galAcctId = request.getAttribute("galAcctId", null);
/*    */     
/* 53 */     GalSearchParams params = new GalSearchParams(account, zsc);
/* 54 */     params.setType(type);
/* 55 */     params.setRequest(request);
/* 56 */     params.setQuery(name);
/* 57 */     params.setLimit(account.getContactAutoCompleteMaxResults());
/* 58 */     params.setNeedCanExpand(needCanExpand);
/* 59 */     params.setResponseName(AccountConstants.AUTO_COMPLETE_GAL_RESPONSE);
/* 60 */     if (galAcctId != null)
/* 61 */       params.setGalSyncAccount(Provisioning.getInstance().getAccountById(galAcctId));
/* 62 */     GalSearchControl gal = new GalSearchControl(params);
/* 63 */     gal.autocomplete();
/* 64 */     return params.getResultCallback().getResponse();
/*    */   }
/*    */   
/*    */   public boolean needsAuth(Map<String, Object> context)
/*    */   {
/* 69 */     return true;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/account/AutoCompleteGal.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */